<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>坯料计算</title>

	<style>
		*{
			margin: 0;

			padding: 0;
		}

		table{
			font-size: 35px;
			margin:0 auto;
			padding: 0;
			margin-top: 50px
		}
		input{
			 width: 85%; 
			 font-size: 35px;
			 
			 text-align: center;
			 height:85px;
			 margin-left: 25px;
			 

		}
		td{
			text-align: center;
		}
		#content{
			
			
			margin: 0 auto;
			margin-top: 30px;
			font-size: 35px;
			height: 200px;

		}
		ul{
			width: 100%;

			margin:0 auto;
			

		}
		ul li{
			float: left;
			list-style: none;
			margin: 50px auto;
			width: 50%;
			text-align: center;
			color: red;
			
		}

		#first li{
			
		}
		button{
			width: 30%;
			font-size: 35px;

		}
		#jisuan{
			margin-top: 100px;
			text-align: center;
		}

		

	</style>
</head>
<body>
	<table border="2px" cellspacing="0" width="80%">
		<tr>
			<th style="height: 85px">坯料计算</th>
		</tr>
		<tr>
			<td><span style="color: red">冲头</span><input placeholder="冲头大小" type="number" name="chongtou" id="chongtou" value="0"></td>
		</tr>
		<tr>
			<td><span style="color: red">高度</span><input placeholder="坯料高度" type="number" name="gaodu" id="gaodu"></td>
		</tr>
		<tr>
			<td><span style="color: red">火耗</span><input placeholder="火耗" type="number" name="huohao" id="huohao" value="1.06"></td>
		</tr>

		<tr>
			<td><span style="color: red">锻重</span><input placeholder="锻件重量" type="number" name="dm" id="dm"></td>
		</tr>

		<tr>
			<td><span style="color: red">外径</span><input placeholder="锻件外径" type="number" name="DD" id="DD"></td>
		</tr>

		<tr>
			<td><span style="color: red">内径</span><input placeholder="锻件内径" type="number" name="dd" id="dd"></td>
		</tr>

		<tr>
			<td><span style="color: red">料圆</span><input placeholder="料圆直径" type="number" name="LD" id="LD"></td>
		</tr>

	</table>

	<div id="content">
		<ul id="first">
			<li id="0">坯料外径：</li>
			<li>毛坯壁厚：</li>
			<li>锻件壁厚：</li>
			<li>料棒长：</li>
			
		</ul>
		<ul id="seconed">
		    <li>下料重量：</li>
			<li>碾扩比：</li>
			<li>长径比：</li>
			<li>压缩比：</li>

		</ul>

	</div>
	<div id="jisuan">

		<button onclick="jisuan()">计算</button>	

	</div>

	<script>

		function jisuan(){

		var  chongtouName="chongtou",gaoduName="gaodu",huohaoName="huohao",dmName="dm",DDName="DD",ddName="dd",LDName="LD";

		var  message={
			chongtou:getInput(chongtouName).valueAsNumber,
			gaodu:getInput(gaoduName).valueAsNumber,
			huohao:getInput(huohaoName).valueAsNumber,
			dm:getInput(dmName).valueAsNumber,
			DD:getInput(DDName).valueAsNumber,
			dd:getInput(ddName).valueAsNumber,
			LD:getInput(LDName).valueAsNumber,
		}

		var pl=(Math.sqrt(message.dm*message.huohao/(1.04*0.00617*0.001*message.gaodu)+message.chongtou*message.chongtou)).toFixed(1);

		var xm=(message.dm*message.huohao).toFixed(1);

		var md=((pl-message.chongtou)/2).toFixed(1);

		var dh=((message.DD-message.dd)/2).toFixed(1);

		var nb=(md/dh).toFixed(2);

		var lb=((message.dm*message.huohao/((message.LD*message.LD)*0.00617*0.001))/message.LD).toFixed(2);


		var l=(xm/((message.LD*message.LD)*0.00617*0.001)).toFixed(1); //料棒长度

		var duncuB=((l-message.gaodu)/l).toFixed(1);//镦粗压缩比


		getInput("first").children[0].innerText="坯料外径："+pl;
		getInput("first").children[1].innerText="毛坯壁厚："+md;
		getInput("first").children[2].innerText="锻件壁厚："+dh;

		getInput("first").children[3].innerText="料棒长："+l;



		getInput("seconed").children[0].innerText="下料重量："+xm;
		getInput("seconed").children[1].innerText="碾扩比："+nb;
		getInput("seconed").children[2].innerText="长径比："+lb;

		getInput("seconed").children[3].innerText="镦粗压缩比："+duncuB;


	}
		
/*获取input元素*/

		function getInput(id){
			var obj = document.getElementById(id);

			return obj;
		}


	</script>
</body>
</html>